package com.hsh.erp.controller;

import com.hsh.erp.domain.common.Result;
import com.hsh.erp.domain.dto.ProductDTO;
import com.hsh.erp.domain.dto.RepositoryDTO;
import com.hsh.erp.domain.vo.ProductVO;
import com.hsh.erp.domain.vo.RepositoryVO;
import com.hsh.erp.service.RepositoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author USER
 * @description 针对表【repository】的数据库操作Service实现
 * @createDate 2024-05-30 16:21:43
 */
@RestController
@RequestMapping("/repository")
@Tag(name = "仓库", description = "仓库")
public class RepositoryController {

    @Resource
    private RepositoryService repositoryService;



    /**
     * 获取所有仓库
     *
     * @return
     */
    @GetMapping("/all")
    @Operation(summary = "获取所有仓库")
    public Result<List<RepositoryDTO>> getAll() {
        return repositoryService.getAll();
    }

    /**
     * 列表查询
     *
     * @param repositoryVO
     * @return
     */
    @GetMapping("/list")
    @Operation(summary = "列表查询")
    public Result<List<RepositoryDTO>> getList(RepositoryVO repositoryVO) {
        return repositoryService.getList(repositoryVO);
    }

    /**
     * 修改一条记录
     *
     * @param repositoryVO
     * @return
     */
    @PostMapping("/updateOne")
    @Operation(summary = "修改一条记录")
    public Result updateOne(@RequestBody RepositoryVO repositoryVO) {
        return repositoryService.updateOne(repositoryVO);
    }

    /**
     * 删除一条记录
     *
     * @param repositoryVO
     * @return
     */
    @PostMapping("/deleteOne")
    @Operation(summary = "删除一条记录")
    public Result deleteOne(@RequestBody RepositoryVO repositoryVO) {
        return repositoryService.deleteOne(repositoryVO);
    }

    /**
     * 新增一条记录
     *
     * @param repositoryVO
     * @return
     */
    @PostMapping("/addOne")
    @Operation(summary = "新增一条记录")
    public Result addOne(@RequestBody RepositoryVO repositoryVO) {
        return repositoryService.addOne(repositoryVO);
    }

    /**
     * 设置为默认仓库，其他仓库设置为非默认仓库
     *
     * @param repositoryVO
     * @return
     */
    @PostMapping("/setDefault")
    @Operation(summary = "设置为默认")
    public Result setDefault(@RequestBody RepositoryVO repositoryVO) {
        return repositoryService.setDefault(repositoryVO);
    }

}




